package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.NewsCatalog;
import cn.wolfcode.trip.base.mapper.NewsCatalogMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.INewsCatalogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
@RequestMapping("/newsCatalog")
public class NewsCatalogController {
    @Autowired
    private INewsCatalogService newsCatalogService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") QueryObject qo){
         model.addAttribute("pageInfo",newsCatalogService.query(qo));
         return "newsCatalog/list";
    }

    @RequestMapping("/saveOrUpdate")
    public String  saveOrUpdate(NewsCatalog newsCatalog){
        newsCatalogService.saveOrUpdate(newsCatalog);
        return "redirect:/newsCatalog/list.do";
    }
}
